home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / OpenTransport / Interfaces / PInterfaces / OpenTransport.p < prev   
Encoding:
Text File  |  1996-11-21  |  63.4 KB  |  1,716 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        OpenTransport.p
  3.  
  4.      Contains:    OpenTransport interfaces
  5.  
  6.      Copyright:    © 1984-1996 by Apple Computer, Inc.
  7.                  All rights reserved.
  8.  
  9. }
  10. {$IFC UNDEFINED UsingIncludes}
  11. {$SETC UsingIncludes := 0}
  12. {$ENDC}
  13.  
  14. {$IFC NOT UsingIncludes}
  15.  UNIT OpenTransport;
  16.  INTERFACE
  17. {$ENDC}
  18.  
  19. {$IFC UNDEFINED __OPENTRANSPORT__}
  20. {$SETC __OPENTRANSPORT__ := 1}
  21.  
  22. {$I+}
  23. {$SETC OpenTransportIncludes := UsingIncludes}
  24. {$SETC UsingIncludes := 1}
  25.  
  26. {$SETC SystemSevenOrLater := 1 }
  27. {$IFC UNDEFINED __TYPES__}
  28. {$I Types.p}
  29. {$ENDC}
  30. {$IFC UNDEFINED __MIXEDMODE__}
  31. {$I MixedMode.p}
  32. {$ENDC}
  33. {
  34.     -------------------------------------------------------------------------
  35.     Some Typedefs for Pascal
  36.     ------------------------------------------------------------------------- 
  37. }
  38.  
  39. {$PUSH}
  40. {$ALIGN MAC68K}
  41. {$LibExport+}
  42.  
  43.  
  44. TYPE
  45.     size_t                                = LONGINT;
  46. {$SETC NULL := 0 }
  47.     uchar_p                                = LONGINT;
  48.     ushort_p                            = LONGINT;
  49.     short_p                                = LONGINT;
  50.     char_p                                = LONGINT;
  51.     boolean_p                            = LONGINT;
  52.     int_t                                = LONGINT;
  53.     uint_t                                = LONGINT;
  54. {$IFC UNDEFINED OTKERNEL }
  55. {$SETC OTKERNEL := 0 }
  56. {$ENDC}
  57. {$IFC UNDEFINED OTUNIXERRORS }
  58. {$SETC OTUNIXERRORS := 0 }
  59. {$ENDC}
  60. {
  61. ******************************************************************************
  62. ** Gestalt values for Open Transport
  63. *******************************************************************************
  64. }
  65.  
  66. CONST
  67.     gestaltOpenTptVersions        = 'otvr';
  68.     gestaltOpenTpt                = 'otan';
  69.     gestaltOpenTptPresentMask    = $00000001;
  70.     gestaltOpenTptLoadedMask    = $00000002;
  71.     gestaltOpenTptAppleTalkPresentMask = $00000004;
  72.     gestaltOpenTptAppleTalkLoadedMask = $00000008;
  73.     gestaltOpenTptTCPPresentMask = $00000010;
  74.     gestaltOpenTptTCPLoadedMask    = $00000020;
  75.     gestaltOpenTptIPXSPXPresentMask = $00000040;
  76.     gestaltOpenTptIPXSPXLoadedMask = $00000080;
  77.     gestaltOpenTptPresentBit    = 0;
  78.     gestaltOpenTptLoadedBit        = 1;
  79.     gestaltOpenTptAppleTalkPresentBit = 2;
  80.     gestaltOpenTptAppleTalkLoadedBit = 3;
  81.     gestaltOpenTptTCPPresentBit    = 4;
  82.     gestaltOpenTptTCPLoadedBit    = 5;
  83.     gestaltOpenTptIPXSPXPresentBit = 6;
  84.     gestaltOpenTptIPXSPXLoadedBit = 7;
  85.  
  86. {
  87. ******************************************************************************
  88. ** Some prefixes for shared libraries
  89. *******************************************************************************
  90. }
  91.     kOTLibraryVersion    =    '1.1';
  92.     kOTLibraryPrefix    =    'OTLib$';
  93.     kOTModulePrefix        =    'OTModl$';
  94.     kOTKernelPrefix        =    'OTKrnl$';
  95.     kOTClientPrefix        =    'OTClnt$';
  96. {
  97. ******************************************************************************
  98. ** Some typedefs used by the OpenTransport system
  99. *******************************************************************************
  100. }
  101. {
  102.     -------------------------------------------------------------------------
  103.     Miscellaneous typedefs
  104.     ------------------------------------------------------------------------- 
  105. }
  106.  
  107. TYPE
  108.     OTTimeout                            = UInt32;
  109.     OTSequence                            = LONGINT;
  110.     OTNameID                            = LONGINT;
  111.     OTReason                            = SInt32;
  112.     OTQLen                                = UInt32;
  113.     OTClient                            = Ptr;
  114.     OTClientName                        = ^UInt8;
  115.     OTCommand                            = LONGINT;
  116.     CStringPtrPtr                        = ^CStringPtr;
  117. {
  118.     -------------------------------------------------------------------------
  119.     OTOpenFlags - flags used for opening providers
  120.     ------------------------------------------------------------------------- 
  121. }
  122.     OTOpenFlags                            = UInt32;
  123.  
  124. CONST
  125.     O_ASYNC                        = $01;
  126.     O_NDELAY                    = $04;
  127.     O_NONBLOCK                    = $04;
  128.  
  129. {
  130.     -------------------------------------------------------------------------
  131.     StdCLib-style Error codes
  132.     ------------------------------------------------------------------------- 
  133. }
  134.  
  135. TYPE
  136.     OTUnixErr                            = UInt16;
  137. {$IFC OTKERNEL OR OTUNIXERRORS }
  138. {
  139.          * There may be some error code confusions with other compiler vendor header
  140.          * files - However, these match both MPW and AIX definitions.
  141.          * We undefine the #defined ones we know about so that we can put them
  142.          * in an enum.
  143. }
  144.  
  145. CONST
  146.     EPERM                        = 1;                            {  Permission denied                     }
  147.     ENOENT                        = 2;                            {  No such file or directory             }
  148.     ENORSRC                        = 3;                            {  No such resource                         }
  149.     EINTR                        = 4;                            {  Interrupted system service             }
  150.     EIO                            = 5;                            {  I/O error                             }
  151.     ENXIO                        = 6;                            {  No such device or address             }
  152.     EBADF                        = 9;                            {  Bad file number                         }
  153.     EAGAIN                        = 11;                            {  Try operation again later             }
  154.     ENOMEM                        = 12;                            {  Not enough space                         }
  155.     EACCES                        = 13;                            {  Permission denied                     }
  156.     EFAULT                        = 14;                            {  Bad address                             }
  157.     EBUSY                        = 16;                            {  Device or resource busy                 }
  158.     EEXIST                        = 17;                            {  File exists                             }
  159.     ENODEV                        = 19;                            {  No such device                         }
  160.     EINVAL                        = 22;                            {  Invalid argument                         }
  161.     ENOTTY                        = 25;                            {  Not a character device                 }
  162.     EPIPE                        = 32;                            {  Broken pipe                             }
  163.     ERANGE                        = 34;                            {  Math result not representable         }
  164.     EDEADLK                        = 35;                            {  Call would block so was aborted         }
  165.     EWOULDBLOCK                    = 35;                            {  Or a deadlock would occur             }
  166.     EALREADY                    = 37;
  167.     ENOTSOCK                    = 38;                            {  Socket operation on non-socket         }
  168.     EDESTADDRREQ                = 39;                            {  Destination address required             }
  169.     EMSGSIZE                    = 40;                            {  Message too long                         }
  170.     EPROTOTYPE                    = 41;                            {  Protocol wrong type for socket         }
  171.     ENOPROTOOPT                    = 42;                            {  Protocol not available                 }
  172.     EPROTONOSUPPORT                = 43;                            {  Protocol not supported                 }
  173.     ESOCKTNOSUPPORT                = 44;                            {  Socket type not supported             }
  174.     EOPNOTSUPP                    = 45;                            {  Operation not supported on socket     }
  175.     EADDRINUSE                    = 48;                            {  Address already in use                 }
  176.     EADDRNOTAVAIL                = 49;                            {  Can't assign requested address         }
  177.     ENETDOWN                    = 50;                            {  Network is down                         }
  178.     ENETUNREACH                    = 51;                            {  Network is unreachable                 }
  179.     ENETRESET                    = 52;                            {  Network dropped connection on reset     }
  180.     ECONNABORTED                = 53;                            {  Software caused connection abort         }
  181.     ECONNRESET                    = 54;                            {  Connection reset by peer                 }
  182.     ENOBUFS                        = 55;                            {  No buffer space available             }
  183.     EISCONN                        = 56;                            {  Socket is already connected             }
  184.     ENOTCONN                    = 57;                            {  Socket is not connected                 }
  185.     ESHUTDOWN                    = 58;                            {  Can't send after socket shutdown         }
  186.     ETOOMANYREFS                = 59;                            {  Too many references: can't splice     }
  187.     ETIMEDOUT                    = 60;                            {  Connection timed out                     }
  188.     ECONNREFUSED                = 61;                            {  Connection refused                     }
  189.     EHOSTDOWN                    = 64;                            {  Host is down                             }
  190.     EHOSTUNREACH                = 65;                            {  No route to host                         }
  191.     EPROTO                        = 70;
  192.     ETIME                        = 71;
  193.     ENOSR                        = 72;
  194.     EBADMSG                        = 73;
  195.     ECANCEL                        = 74;
  196.     ENOSTR                        = 75;
  197.     ENODATA                        = 76;
  198.     EINPROGRESS                    = 77;
  199.     ESRCH                        = 78;
  200.     ENOMSG                        = 79;
  201.     ELASTERRNO                    = 79;
  202.  
  203. {$ENDC}
  204. {
  205.     -------------------------------------------------------------------------
  206.     Open Transport/XTI Error codes
  207.     ------------------------------------------------------------------------- 
  208. }
  209.  
  210. TYPE
  211.     OTXTIErr                            = UInt16;
  212.  
  213. CONST
  214.     TSUCCESS                    = 0;                            {  No Error occurred                         }
  215.     TBADADDR                    = 1;                            {  A Bad address was specified                 }
  216.     TBADOPT                        = 2;                            {  A Bad option was specified                 }
  217.     TACCES                        = 3;                            {  Missing access permission                 }
  218.     TBADF                        = 4;                            {  Bad provider reference                     }
  219.     TNOADDR                        = 5;                            {  No address was specified                     }
  220.     TOUTSTATE                    = 6;                            {  Call issued in wrong state                 }
  221.     TBADSEQ                        = 7;                            {  Sequence specified does not exist         }
  222.     TSYSERR                        = 8;                            {  A system error occurred                     }
  223.     TLOOK                        = 9;                            {  An event occurred - call Look()             }
  224.     TBADDATA                    = 10;                            {  An illegal amount of data was specified     }
  225.     TBUFOVFLW                    = 11;                            {  Passed buffer not big enough                 }
  226.     TFLOW                        = 12;                            {  Provider is flow-controlled                 }
  227.     TNODATA                        = 13;                            {  No data available for reading             }
  228.     TNODIS                        = 14;                            {  No disconnect indication available         }
  229.     TNOUDERR                    = 15;                            {  No Unit Data Error indication available     }
  230.     TBADFLAG                    = 16;                            {  A Bad flag value was supplied             }
  231.     TNOREL                        = 17;                            {  No orderly release indication available     }
  232.     TNOTSUPPORT                    = 18;                            {  Command is not supported                     }
  233.     TSTATECHNG                    = 19;                            {  State is changing - try again later         }
  234.     TNOSTRUCTYPE                = 20;                            {  Bad structure type requested for OTAlloc     }
  235.     TBADNAME                    = 21;                            {  A bad endpoint name was supplied             }
  236.     TBADQLEN                    = 22;                            {  A Bind to an in-use address with qlen > 0 }
  237.     TADDRBUSY                    = 23;                            {  Address requested is already in use         }
  238.     TINDOUT                        = 24;                            {  Accept failed because of pending listen     }
  239.     TPROVMISMATCH                = 25;                            {  Tried to accept on incompatible endpoint     }
  240.     TRESQLEN                    = 26;
  241.     TRESADDR                    = 27;
  242.     TQFULL                        = 28;
  243.     TPROTO                        = 29;                            {  An unspecified provider error occurred     }
  244.     TBADSYNC                    = 30;                            {  A synchronous call at interrupt time         }
  245.     TCANCELED                    = 31;                            {  The command was cancelled                 }
  246.     TLASTXTIERROR                = 31;
  247.  
  248. {
  249.     -------------------------------------------------------------------------
  250.     Standard negative error codes conforming to both the Open Transport/XTI
  251.     errors and the Exxxxx StdCLib errors.
  252.     These are returned as OSStatus' from functions, and to the OTResult parameter
  253.     of a notification function or method.  However, OTResult may sometimes
  254.     contain other values depending on the notification.
  255.     ------------------------------------------------------------------------- 
  256. }
  257.  
  258. TYPE
  259.     OTResult                            = SInt32;
  260. {
  261.          * These map the Open Transport/XTI errors (the Txxxx error codes), and the
  262.          * StdCLib Exxxx error codes into unique spaces in the Apple OSStatus space.
  263. }
  264.  
  265. CONST
  266.     kOTNoError                    = 0;                            {  No Error occurred                         }
  267.     kOTOutOfMemoryErr            = -3211;
  268.     kOTNotFoundErr                = -3201;
  269.     kOTDuplicateFoundErr        = -3216;
  270.     kOTBadAddressErr            = -3150;                        {  -3150 A Bad address was specified                 }
  271.     kOTBadOptionErr                = -3151;                        {  -3151 A Bad option was specified                     }
  272.     kOTAccessErr                = -3152;                        {  -3152 Missing access permission                     }
  273.     kOTBadReferenceErr            = -3153;                        {  -3153 Bad provider reference                         }
  274.     kOTNoAddressErr                = -3154;                        {  -3154 No address was specified                     }
  275.     kOTOutStateErr                = -3155;                        {  -3155 Call issued in wrong state                     }
  276.     kOTBadSequenceErr            = -3156;                        {  -3156 Sequence specified does not exist             }
  277.     kOTSysErrorErr                = -3157;                        {  -3157 A system error occurred                     }
  278.     kOTLookErr                    = -3158;                        {  -3158 An event occurred - call Look()             }
  279.     kOTBadDataErr                = -3159;                        {  -3159 An illegal amount of data was specified     }
  280.     kOTBufferOverflowErr        = -3160;                        {  -3160 Passed buffer not big enough                 }
  281.     kOTFlowErr                    = -3161;                        {  -3161 Provider is flow-controlled                 }
  282.     kOTNoDataErr                = -3162;                        {  -3162 No data available for reading                 }
  283.     kOTNoDisconnectErr            = -3163;                        {  -3163 No disconnect indication available             }
  284.     kOTNoUDErrErr                = -3164;                        {  -3164 No Unit Data Error indication available     }
  285.     kOTBadFlagErr                = -3165;                        {  -3165 A Bad flag value was supplied                 }
  286.     kOTNoReleaseErr                = -3166;                        {  -3166 No orderly release indication available     }
  287.     kOTNotSupportedErr            = -3167;                        {  -3167 Command is not supported                     }
  288.     kOTStateChangeErr            = -3168;                        {  -3168 State is changing - try again later         }
  289.     kOTNoStructureTypeErr        = -3169;                        {  -3169 Bad structure type requested for OTAlloc     }
  290.     kOTBadNameErr                = -3170;                        {  -3170 A bad endpoint name was supplied             }
  291.     kOTBadQLenErr                = -3171;                        {  -3171 A Bind to an in-use addr with qlen > 0         }
  292.     kOTAddressBusyErr            = -3172;                        {  -3172 Address requested is already in use         }
  293.     kOTIndOutErr                = -3173;                        {  -3173 Accept failed because of pending listen     }
  294.     kOTProviderMismatchErr        = -3174;                        {  -3174 Tried to accept on incompatible endpoint     }
  295.     kOTResQLenErr                = -3175;                        {  -3175                                             }
  296.     kOTResAddressErr            = -3176;                        {  -3176                                             }
  297.     kOTQFullErr                    = -3177;                        {  -3177                                             }
  298.     kOTProtocolErr                = -3178;                        {  -3178 An unspecified provider error occurred         }
  299.     kOTBadSyncErr                = -3179;                        {  -3179 A synchronous call at interrupt time         }
  300.     kOTCanceledErr                = -3180;                        {  -3180 The command was cancelled                     }
  301.     kEPERMErr                    = -3200;                        {   Permission denied                     }
  302.     kENOENTErr                    = -3201;                        {   No such file or directory             }
  303.     kENORSRCErr                    = -3202;                        {   No such resource                     }
  304.     kEINTRErr                    = -3203;                        {   Interrupted system service             }
  305.     kEIOErr                        = -3204;                        {   I/O error                             }
  306.     kENXIOErr                    = -3205;                        {   No such device or address             }
  307.     kEBADFErr                    = -3208;                        {   Bad file number                         }
  308.     kEAGAINErr                    = -3210;                        {   Try operation again later             }
  309.     kENOMEMErr                    = -3211;                        {   Not enough space                     }
  310.     kEACCESErr                    = -3212;                        {   Permission denied                     }
  311.     kEFAULTErr                    = -3213;                        {   Bad address                             }
  312.     kEBUSYErr                    = -3215;                        {   Device or resource busy                 }
  313.     kEEXISTErr                    = -3216;                        {   File exists                             }
  314.     kENODEVErr                    = -3218;                        {   No such device                         }
  315.     kEINVALErr                    = -3221;                        {   Invalid argument                     }
  316.     kENOTTYErr                    = -3224;                        {   Not a character device                 }
  317.     kEPIPEErr                    = -3231;                        {   Broken pipe                             }
  318.     kERANGEErr                    = -3233;                        {   Message size too large for STREAM     }
  319.     kEWOULDBLOCKErr                = -3234;                        {   Call would block, so was aborted     }
  320.     kEDEADLKErr                    = -3234;                        {   or a deadlock would occur             }
  321.     kEALREADYErr                = -3236;                        {                                           }
  322.     kENOTSOCKErr                = -3237;                        {   Socket operation on non-socket         }
  323.     kEDESTADDRREQErr            = -3238;                        {   Destination address required         }
  324.     kEMSGSIZEErr                = -3239;                        {   Message too long                     }
  325.     kEPROTOTYPEErr                = -3240;                        {   Protocol wrong type for socket         }
  326.     kENOPROTOOPTErr                = -3241;                        {   Protocol not available                 }
  327.     kEPROTONOSUPPORTErr            = -3242;                        {   Protocol not supported                 }
  328.     kESOCKTNOSUPPORTErr            = -3243;                        {   Socket type not supported             }
  329.     kEOPNOTSUPPErr                = -3244;                        {   Operation not supported on socket     }
  330.     kEADDRINUSEErr                = -3247;                        {   Address already in use                 }
  331.     kEADDRNOTAVAILErr            = -3248;                        {   Can't assign requested address         }
  332.     kENETDOWNErr                = -3249;                        {   Network is down                         }
  333.     kENETUNREACHErr                = -3250;                        {   Network is unreachable                 }
  334.     kENETRESETErr                = -3251;                        {   Network dropped connection on reset     }
  335.     kECONNABORTEDErr            = -3252;                        {   Software caused connection abort     }
  336.     kECONNRESETErr                = -3253;                        {   Connection reset by peer             }
  337.     kENOBUFSErr                    = -3254;                        {   No buffer space available             }
  338.     kEISCONNErr                    = -3255;                        {   Socket is already connected             }
  339.     kENOTCONNErr                = -3256;                        {   Socket is not connected                 }
  340.     kESHUTDOWNErr                = -3257;                        {   Can't send after socket shutdown     }
  341.     kETOOMANYREFSErr            = -3258;                        {   Too many references: can't splice     }
  342.     kETIMEDOUTErr                = -3259;                        {   Connection timed out                 }
  343.     kECONNREFUSEDErr            = -3260;                        {   Connection refused                     }
  344.     kEHOSTDOWNErr                = -3263;                        {   Host is down                         }
  345.     kEHOSTUNREACHErr            = -3264;                        {   No route to host                     }
  346.     kEPROTOErr                    = -3269;                        {                                           }
  347.     kETIMEErr                    = -3270;                        {                                           }
  348.     kENOSRErr                    = -3271;                        {                                           }
  349.     kEBADMSGErr                    = -3272;                        {                                           }
  350.     kECANCELErr                    = -3273;                        {                                           }
  351.     kENOSTRErr                    = -3274;                        {                                           }
  352.     kENODATAErr                    = -3275;                        {                                           }
  353.     kEINPROGRESSErr                = -3276;                        {                                           }
  354.     kESRCHErr                    = -3277;                        {                                           }
  355.     kENOMSGErr                    = -3278;                        {                                           }
  356.     kOTClientNotInittedErr        = -3279;
  357.     kOTPortHasDiedErr            = -3280;
  358.     kOTPortWasEjectedErr        = -3281;
  359.     kOTBadConfigurationErr        = -3282;
  360.     kOTConfigurationChangedErr    = -3283;
  361.     kOTUserRequestedErr            = -3284;
  362.     kOTPortLostConnection        = -3285;
  363.  
  364. {
  365.     -------------------------------------------------------------------------
  366.     OTAddressType - defines the address type for the OTAddress
  367.     ------------------------------------------------------------------------- 
  368. }
  369.  
  370. TYPE
  371.     OTAddressType                        = UInt16;
  372.  
  373. CONST
  374.     kOTGenericName                = 0;
  375.  
  376. {
  377.     -------------------------------------------------------------------------
  378.     OTAddress - Generic OpenTransport protocol address
  379.     ------------------------------------------------------------------------- 
  380. }
  381.  
  382. TYPE
  383.     OTAddressPtr = ^OTAddress;
  384.     OTAddress = RECORD
  385.         fAddressType:            OTAddressType;
  386.         fAddress:                SInt8;
  387.     END;
  388.  
  389. {
  390.     -------------------------------------------------------------------------
  391.     OTStructType - defines the structure type for the OTAlloc call
  392.     ------------------------------------------------------------------------- 
  393. }
  394.     OTStructType                        = UInt32;
  395.  
  396. CONST
  397.     T_BIND                        = 1;
  398.     T_OPTMGMT                    = 2;
  399.     T_CALL                        = 3;
  400.     T_DIS                        = 4;
  401.     T_UNITDATA                    = 5;
  402.     T_UDERROR                    = 6;
  403.     T_INFO                        = 7;
  404.     T_REPLYDATA                    = 8;
  405.     T_REQUESTDATA                = 9;
  406.     T_UNITREQUEST                = 10;
  407.     T_UNITREPLY                    = 11;
  408.  
  409. {
  410.     -------------------------------------------------------------------------
  411.     OTFlags - flags for sending and receiving data
  412.     ------------------------------------------------------------------------- 
  413. }
  414.  
  415. TYPE
  416.     OTFlags                                = UInt32;
  417.  
  418. CONST
  419.     T_MORE                        = $0001;                        {  More data to come in message         }
  420.     T_EXPEDITED                    = $0002;                        {  Data is expedited, if possible     }
  421.     T_ACKNOWLEDGED                = $0004;                        {  Acknowledge transaction             }
  422.     T_PARTIALDATA                = $0008;                        {  Partial data - more coming         }
  423.     T_NORECEIPT                    = $0010;                        {  No event on transaction done         }
  424.     T_TIMEDOUT                    = $0020;                        {  Reply timed out                     }
  425.  
  426. {
  427.     -------------------------------------------------------------------------
  428.     OTBand - a band value when reading priority messages
  429.     ------------------------------------------------------------------------- 
  430. }
  431.  
  432. TYPE
  433.     OTBand                                = UInt32;
  434. {
  435.     -------------------------------------------------------------------------
  436.     Reference values
  437.     ------------------------------------------------------------------------- 
  438. }
  439.     StreamRef                            = Ptr;
  440.     ProviderRef                            = Ptr;
  441.     EndpointRef                            = Ptr;
  442.     MapperRef                            = Ptr;
  443.  
  444. CONST
  445.     kOTInvalidRef                = 0;
  446.     kOTInvalidStreamRef            = 0;
  447.     kOTInvalidProviderRef        = 0;
  448.     kOTInvalidEndpointRef        = 0;
  449.     kOTInvalidMapperRef            = 0;
  450.  
  451. {
  452.     -------------------------------------------------------------------------
  453.     OTEventCode values for Open Transport - These are the event codes that
  454.     are sent to notification routine during asynchronous processing.
  455.     ------------------------------------------------------------------------- 
  456. }
  457.  
  458. TYPE
  459.     OTEventCode                            = UInt32;
  460. {
  461.      * Function definition to handle notification from providers
  462.      *
  463.      * This is never a UniversalProcPtr.
  464. }
  465.     OTNotifyProcPtr = ProcPtr;  { PROCEDURE OTNotify(contextPtr: UNIV Ptr; code: OTEventCode; result: OTResult; cookie: UNIV Ptr); }
  466.  
  467. {
  468.      * These will be returned by the T_LOOK function, or will be returned
  469.      * if asynchronous notification is used.
  470. }
  471.  
  472. CONST
  473.     T_LISTEN                    = $0001;                        {  An connection request is available      }
  474.     T_CONNECT                    = $0002;                        {  Confirmation of a connect request     }
  475.     T_DATA                        = $0004;                        {  Standard data is available             }
  476.     T_EXDATA                    = $0008;                        {  Expedited data is available             }
  477.     T_DISCONNECT                = $0010;                        {  A disconnect is available             }
  478.     T_ERROR                        = $0020;                        {  obsolete/unused in library             }
  479.     T_UDERR                        = $0040;                        {  A Unit Data Error has occurred         }
  480.     T_ORDREL                    = $0080;                        {  An orderly release is available         }
  481.     T_GODATA                    = $0100;                        {  Flow control lifted on standard data     }
  482.     T_GOEXDATA                    = $0200;                        {  Flow control lifted on expedited data }
  483.     T_REQUEST                    = $0400;                        {  An Incoming request is available         }
  484.     T_REPLY                        = $0800;                        {  An Incoming reply is available         }
  485.     T_PASSCON                    = $1000;                        {  State is now T_DATAXFER                 }
  486.     T_RESET                        = $2000;                        {  Protocol has been reset                 }
  487.  
  488. {
  489.      * kPRIVATEEVENT + 1 through kPRIVATEEVENT + 0xffff
  490.      *        may be used for any private event codes desired.
  491.      *        All other event codes are reserved for Apple Computer, Inc.
  492.      *        use only.
  493. }
  494.     kPRIVATEEVENT                = $10000000;
  495.  
  496. {
  497.      * These are only returned if asynchronous notification is being used
  498. }
  499.     kCOMPLETEEVENT                = $20000000;
  500.     T_BINDCOMPLETE                = $20000001;                    {  Bind call is complete                 }
  501.     T_UNBINDCOMPLETE            = $20000002;                    {  Unbind call is complete                 }
  502.     T_ACCEPTCOMPLETE            = $20000003;                    {  Accept call is complete                 }
  503.     T_REPLYCOMPLETE                = $20000004;                    {  SendReply call is complete             }
  504.     T_DISCONNECTCOMPLETE        = $20000005;                    {  Disconnect call is complete             }
  505.     T_OPTMGMTCOMPLETE            = $20000006;                    {  OptMgmt call is complete                 }
  506.     T_OPENCOMPLETE                = $20000007;                    {  An Open call is complete                 }
  507.     T_GETPROTADDRCOMPLETE        = $20000008;                    {  GetProtAddress call is complete         }
  508.     T_RESOLVEADDRCOMPLETE        = $20000009;                    {  A ResolveAddress call is complet         }
  509.     T_GETINFOCOMPLETE            = $2000000A;                    {  A GetInfo call is complete             }
  510.     T_SYNCCOMPLETE                = $2000000B;                    {  A Sync call is complete                 }
  511.     T_MEMORYRELEASED            = $2000000C;                    {  No-copy memory was released             }
  512.     T_REGNAMECOMPLETE            = $2000000D;                    {  A RegisterName call is complete         }
  513.     T_DELNAMECOMPLETE            = $2000000E;                    {  A DeleteName call is complete         }
  514.     T_LKUPNAMECOMPLETE            = $2000000F;                    {  A LookupName call is complete         }
  515.     T_LKUPNAMERESULT            = $20000010;                    {  A LookupName is returning a name         }
  516.     kOTSyncIdleEvent            = $20000011;                    {  Synchronous call Idle event             }
  517.  
  518. {
  519.      * Events for streams - not normally seen by clients.
  520. }
  521.     kSTREAMEVENT                = $21000000;
  522.     kGetmsgEvent                = $21000002;                    {  A GetMessage call is complete         }
  523.     kStreamReadEvent            = $21000003;                    {  A Read call is complete                 }
  524.     kStreamWriteEvent            = $21000004;                    {  A Write call is complete                 }
  525.     kStreamIoctlEvent            = $21000005;                    {  An Ioctl call is complete             }
  526.     kStreamOpenEvent            = $21000007;                    {  An OpenStream call is complete         }
  527.     kPollEvent                    = $21000008;                    {  A Poll call is complete                 }
  528.     kSIGNALEVENT                = $22000000;                    {  A signal has arrived from the STREAM     }
  529.     kPROTOCOLEVENT                = $23000000;                    {  Some event from the protocols         }
  530.  
  531. {
  532.      * These are miscellaneous events that could be sent to a provider
  533. }
  534.     kOTProviderIsDisconnected    = $23000001;                    {  Provider is temporarily off-line         }
  535.     kOTProviderIsReconnected    = $23000002;                    {  Provider is now back on-line             }
  536.  
  537. {
  538.      * These are system events sent to each provider.
  539. }
  540.     kOTProviderWillClose        = $24000001;                    {  Provider will close immediately         }
  541.     kOTProviderIsClosed            = $24000002;                    {  Provider was closed                     }
  542.  
  543. {
  544.      * These are system events sent to registered clients
  545.      *
  546.      * result code is 0, cookie is the OTPortRef
  547. }
  548.     kOTPortDisabled                = $25000001;                    {  Port is now disabled                     }
  549.     kOTPortEnabled                = $25000002;                    {  Port is now enabled                     }
  550.     kOTPortOffline                = $25000003;                    {  Port is now offline                     }
  551.     kOTPortOnline                = $25000004;                    {  Port is now online                     }
  552.  
  553. {
  554.      * result is a reason for the close request, cookie is a pointer to the 
  555.      * OTPortCloseStruct structure.
  556. }
  557.     kOTClosePortRequest            = $25000005;                    {  Request to close/yield                 }
  558.     kOTYieldPortRequest            = $25000005;                    {  Request to close/yield                 }
  559.  
  560. {
  561.      * A new port has been registered, cookie is the OTPortRef
  562. }
  563.     kOTNewPortRegistered        = $25000006;                    {  New port has been registered             }
  564.  
  565. {
  566.      * These are events sent to the configuration management infrastructure 
  567. }
  568.     kOTConfigurationChanged        = $26000001;                    {  Protocol configuration changed         }
  569.     kOTSystemSleep                = $26000002;
  570.     kOTSystemShutdown            = $26000003;
  571.     kOTSystemAwaken                = $26000004;
  572.     kOTSystemIdle                = $26000005;
  573.     kOTSystemSleepPrep            = $26000006;
  574.     kOTSystemShutdownPrep        = $26000007;
  575.     kOTSystemAwakenPrep            = $26000008;
  576.  
  577. {
  578.     -------------------------------------------------------------------------
  579.     Signals that are generated by a stream.  Add these values to
  580.     kSIGNALEVENT to determine what event you are receiving.
  581.     ------------------------------------------------------------------------- 
  582. }
  583.     SIGHUP                        = 1;
  584.     SIGURG                        = 16;
  585.     SIGPOLL                        = 30;
  586.  
  587. {
  588.     -------------------------------------------------------------------------
  589.     Option Management equates
  590.     ------------------------------------------------------------------------- 
  591. }
  592. {
  593.     ** The XTI Level number of a protocol
  594. }
  595.  
  596. TYPE
  597.     OTXTILevel                            = UInt32;
  598.  
  599. CONST
  600.     XTI_GENERIC                    = $FFFF;                        {  level to match any protocol     }
  601.  
  602. {
  603.     ** The XTI name of a protocol option
  604. }
  605.  
  606. TYPE
  607.     OTXTIName                            = UInt32;
  608. {
  609.          * XTI names for options used with XTI_GENERIC above
  610. }
  611.  
  612. CONST
  613.     XTI_DEBUG                    = $0001;
  614.     XTI_LINGER                    = $0080;
  615.     XTI_RCVBUF                    = $1002;
  616.     XTI_RCVLOWAT                = $1004;
  617.     XTI_SNDBUF                    = $1001;
  618.     XTI_SNDLOWAT                = $1003;
  619.     XTI_PROTOTYPE                = $1005;
  620.  
  621. {
  622.          * Generic options that can be used with any protocol
  623.          * that understands them
  624. }
  625.     OPT_CHECKSUM                = $0600;                        {  Set checksumming = UInt32 - 0 or 1) }
  626.     OPT_RETRYCNT                = $0601;                        {  Set a retry counter = UInt32 (0 = infinite) }
  627.     OPT_INTERVAL                = $0602;                        {  Set a retry interval = UInt32 milliseconds }
  628.     OPT_ENABLEEOM                = $0603;                        {  Enable the EOM indication = UInt8 (0 or 1) }
  629.     OPT_SELFSEND                = $0604;                        {  Enable Self-sending on broadcasts = UInt32 (0 or 1) }
  630.     OPT_SERVERSTATUS            = $0605;                        {  Set Server Status (format is proto dependent) }
  631.     OPT_ALERTENABLE                = $0606;                        {  Enable/Disable protocol alerts }
  632.     OPT_KEEPALIVE                = $0008;                        {  See t_keepalive structure }
  633.  
  634. {
  635. ******************************************************************************
  636. ** Definitions not associated with a Typedef
  637. *******************************************************************************
  638. }
  639. {
  640.     -------------------------------------------------------------------------
  641.     IOCTL values for the OpenTransport system
  642.     ------------------------------------------------------------------------- 
  643. }
  644.     MIOC_STREAMIO                = 65;                            {  Basic Stream ioctl() cmds - I_PUSH, I_LOOK, etc.  }
  645.     MIOC_STRLOG                    = 98;                            {  ioctl's for Mentat's log device  }
  646.     MIOC_SAD                    = 103;                            {  ioctl's for Mentat's sad module  }
  647.     MIOC_ARP                    = 104;                            {  ioctl's for Mentat's arp module  }
  648.     MIOC_TCP                    = 107;                            {  tcp.h ioctl's  }
  649.     MIOC_DLPI                    = 108;                            {  dlpi.h additions  }
  650.     MIOC_OT                        = 79;                            {  ioctls for Open Transport     }
  651.     MIOC_ATALK                    = 84;                            {  ioctl's for AppleTalk     }
  652.     MIOC_SRL                    = 85;                            {  ioctl's for Serial         }
  653.     MIOC_SRL_HIGH                = $5500;                        {  ioctls for Serial            'U' << 8  }
  654.     MIOC_OT_HIGH                = $4F00;                        {  ioctls for Open Transport    'O' << 8  }
  655.     MIOC_SIO_HIGH                = $4100;                        {  ioctls for StreamIO            'A' << 8  }
  656.     MIOC_CFIG                    = 122;                            {  ioctl's for private configuration  }
  657.  
  658.     I_STR                        = $4108;
  659.     I_FIND                        = $410B;
  660.     I_LIST                        = $4116;
  661.     I_OTGetMiscellaneousEvents    = $4F01;                        {  sign up for Misc Events                     }
  662.     I_OTSetFramingType            = $4F02;                        {  Set framing option for link                 }
  663.     kOTGetFramingValue            = $FFFFFFFF;                    {  Use this value to read framing             }
  664.     I_OTSetRawMode                = $4F03;                        {  Set raw mode for link                     }
  665.     I_OTConnect                    = $4F04;                        {  Generic connect request for links         }
  666.     I_OTDisconnect                = $4F05;                        {  Generic disconnect request for links         }
  667.     I_OTScript                    = $4F06;                        {  Send a script to a module                 }
  668.  
  669. {
  670.      * Structure for the I_OTScript Ioctl.
  671. }
  672.  
  673. TYPE
  674.     OTScriptInfoPtr = ^OTScriptInfo;
  675.     OTScriptInfo = RECORD
  676.         fScriptType:            UInt32;
  677.         fTheScript:                Ptr;
  678.         fScriptLength:            UInt32;
  679.     END;
  680.  
  681. {
  682.      * structure of ioctl data for I_STR IOCtls
  683. }
  684.     strioctlPtr = ^strioctl;
  685.     strioctl = RECORD
  686.         ic_cmd:                    int_t;                                    {  downstream command     }
  687.         ic_timout:                int_t;                                    {  ACK/NAK timeout         }
  688.         ic_len:                    int_t;                                    {  length of data arg     }
  689.         ic_dp:                    CStringPtr;                                {  ptr to data arg         }
  690.     END;
  691.  
  692. {
  693.     -------------------------------------------------------------------------
  694.     Maximum size of a provider name, and maximum size of a STREAM module name.
  695.     This module name is smaller than the maximum size of a TProvider to allow
  696.     for 4 characters of extra "minor number" information that might be 
  697.     potentially in a TProvider name
  698.     ------------------------------------------------------------------------- 
  699. }
  700.  
  701. CONST
  702.     kMaxModuleNameLength        = 31;
  703.     kMaxModuleNameSize            = 32;
  704.     kMaxProviderNameLength        = 35;
  705.     kMaxProviderNameSize        = 36;
  706.     kMaxSlotIDLength            = 7;
  707.     kMaxSlotIDSize                = 8;
  708.     kMaxResourceInfoLength        = 31;
  709.     kMaxResourceInfoSize        = 32;
  710.  
  711. {
  712.     -------------------------------------------------------------------------
  713.     These values are used in the "fields" parameter of the OTAlloc call
  714.     to define which fields of the structure should be allocated.
  715.     ------------------------------------------------------------------------- 
  716. }
  717.     T_ADDR                        = $01;
  718.     T_OPT                        = $02;
  719.     T_UDATA                        = $04;
  720.     T_ALL                        = $FFFF;
  721.  
  722. {
  723.     -------------------------------------------------------------------------
  724.     These are the potential values returned by OTGetEndpointState and OTSync
  725.     which represent the state of an endpoint
  726.     ------------------------------------------------------------------------- 
  727. }
  728.     T_UNINIT                    = 0;                            {  addition to standard xti.h     }
  729.     T_UNBND                        = 1;                            {  unbound                         }
  730.     T_IDLE                        = 2;                            {  idle                             }
  731.     T_OUTCON                    = 3;                            {  outgoing connection pending     }
  732.     T_INCON                        = 4;                            {  incoming connection pending     }
  733.     T_DATAXFER                    = 5;                            {  data transfer                 }
  734.     T_OUTREL                    = 6;                            {  outgoing orderly release         }
  735.     T_INREL                        = 7;                            {  incoming orderly release         }
  736.  
  737. {
  738.     -------------------------------------------------------------------------
  739.     Flags used by option management calls to request services
  740.     ------------------------------------------------------------------------- 
  741. }
  742.     T_NEGOTIATE                    = $0004;
  743.     T_CHECK                        = $0008;
  744.     T_DEFAULT                    = $0010;
  745.     T_CURRENT                    = $0080;
  746.  
  747. {
  748.     -------------------------------------------------------------------------
  749.     Flags used by option management calls to return results
  750.     ------------------------------------------------------------------------- 
  751. }
  752.     T_SUCCESS                    = $0020;
  753.     T_FAILURE                    = $0040;
  754.     T_PARTSUCCESS                = $0100;
  755.     T_READONLY                    = $0200;
  756.     T_NOTSUPPORT                = $0400;
  757.  
  758. {
  759.     -------------------------------------------------------------------------
  760.     General definitions
  761.     ------------------------------------------------------------------------- 
  762. }
  763.     T_YES                        = 1;
  764.     T_NO                        = 0;
  765.     T_UNUSED                    = -1;
  766.     T_NULL                        = 0;
  767.     T_ABSREQ                    = $8000;
  768.  
  769. {
  770.     -------------------------------------------------------------------------
  771.     Option Management definitions
  772.     ------------------------------------------------------------------------- 
  773. }
  774.     T_UNSPEC                    = $FFFFFFFD;
  775.     T_ALLOPT                    = 0;
  776.  
  777. {
  778.  This macro will align return the value of "len", rounded up to the next
  779.  4-byte boundary.
  780. }
  781. {
  782.  This macro will return the next option in the buffer, given the previous option
  783.  in the buffer, returning NULL if there are no more.
  784.  You start off by setting prevOption = (TOption*)theBuffer
  785.  (Use OTNextOption for a more thorough check - it ensures the end
  786.   of the option is in the buffer as well.)
  787. }
  788. {
  789. ******************************************************************************
  790. ** Structures and forward declarations
  791. **
  792. ** From here on down, all structures are aligned the same on 68K and powerpc
  793. *******************************************************************************
  794. }
  795. {
  796.     -------------------------------------------------------------------------
  797.     OTConfiguration structure - this is a "black box" structure used to
  798.     define the configuration of a provider or endpoint.
  799.     ------------------------------------------------------------------------- 
  800. }
  801.  
  802. TYPE
  803.     OTConfigurationPtr = ^OTConfiguration;
  804.     OTConfiguration = RECORD
  805.     END;
  806.  
  807. {
  808.     -------------------------------------------------------------------------
  809.     Option Management structures
  810.     ------------------------------------------------------------------------- 
  811. }
  812. {
  813.      * Structure used with OPT_KEEPALIVE option.
  814. }
  815.     t_kpalivePtr = ^t_kpalive;
  816.     t_kpalive = RECORD
  817.         kp_onoff:                LONGINT;                                {  option on/off         }
  818.         kp_timeout:                LONGINT;                                {  timeout in minutes     }
  819.     END;
  820.  
  821. {
  822.      * Structure used with XTI_LINGER option
  823. }
  824.     t_lingerPtr = ^t_linger;
  825.     t_linger = RECORD
  826.         l_onoff:                LONGINT;                                {  option on/off  }
  827.         l_linger:                LONGINT;                                {  linger time  }
  828.     END;
  829.  
  830. {
  831.     -------------------------------------------------------------------------
  832.     TEndpointInfo - this structure is returned from the GetEndpointInfo call
  833.     and contains information about an endpoint
  834.     ------------------------------------------------------------------------- 
  835. }
  836.     TEndpointInfoPtr = ^TEndpointInfo;
  837.     TEndpointInfo = RECORD
  838.         addr:                    SInt32;                                    {  Maximum size of an address             }
  839.         options:                SInt32;                                    {  Maximum size of options                 }
  840.         tsdu:                    SInt32;                                    {  Standard data transmit unit size         }
  841.         etsdu:                    SInt32;                                    {  Expedited data transmit unit size     }
  842.         connect:                SInt32;                                    {  Maximum data size on connect             }
  843.         discon:                    SInt32;                                    {  Maximum data size on disconnect         }
  844.         servtype:                UInt32;                                    {  service type (see below for values)     }
  845.         flags:                    UInt32;                                    {  Flags (see below for values)             }
  846.     END;
  847.  
  848. {
  849.      * Values returned in servtype field of TEndpointInfo
  850. }
  851.  
  852. CONST
  853.     T_COTS                        = 1;                            {  Connection-mode service                                 }
  854.     T_COTS_ORD                    = 2;                            {  Connection service with orderly release                 }
  855.     T_CLTS                        = 3;                            {  Connectionless-mode service                             }
  856.     T_TRANS                        = 5;                            {  Connection-mode transaction service                     }
  857.     T_TRANS_ORD                    = 6;                            {  Connection transaction service with orderly release     }
  858.     T_TRANS_CLTS                = 7;                            {  Connectionless transaction service                     }
  859.  
  860. {
  861.      * Values returned in flags field of TEndpointInfo
  862. }
  863.     T_SENDZERO                    = $0001;                        {  supports 0-length TSDU's             }
  864.     T_XPG4_1                    = $0002;                        {  supports the GetProtAddress call     }
  865.     T_CAN_SUPPORT_MDATA            = $10000000;                    {  support M_DATAs on packet protocols     }
  866.     T_CAN_RESOLVE_ADDR            = $40000000;                    {  Supports ResolveAddress call             }
  867.     T_CAN_SUPPLY_MIB            = $20000000;                    {  Supports SNMP MIB data                 }
  868.  
  869. {
  870.      * Values returned in tsdu, etsdu, connect, and discon fields of TEndpointInfo
  871. }
  872.     T_INFINITE                    = -1;                            {  supports infinit amounts of data         }
  873.     T_INVALID                    = -2;                            {  Does not support data transmission     }
  874.  
  875. {
  876.     -------------------------------------------------------------------------
  877.     OTPortRecord
  878.     ------------------------------------------------------------------------- 
  879. }
  880. {
  881.      * Unique identifier for a port
  882. }
  883.  
  884. TYPE
  885.     OTPortRef                            = UInt32;
  886.     OTPortRefPtr                        = ^OTPortRef;
  887. {
  888.      * A couple of special values for the "port type" in an OTPortRef.
  889.      * See OpenTptLinks.h for other values.
  890.      * The device kOTPseudoDevice is used where no other defined
  891.      * device type will work.
  892. }
  893.  
  894. CONST
  895.     kOTNoDeviceType                = 0;
  896.     kOTPseudoDevice                = 1023;
  897.     kOTLastDeviceIndex            = 1022;
  898.     kOTLastSlotNumber            = 255;
  899.     kOTLastOtherNumber            = 255;
  900.  
  901. {
  902.      * kMaxPortNameLength is the maximum size allowed to define
  903.      * a port
  904. }
  905.     kMaxPortNameLength            = 35;
  906.     kMaxPortNameSize            = 36;
  907.  
  908.     kOTInvalidPortRef            = 0;
  909.  
  910. {
  911.      * Equates for the legal Bus-type values
  912. }
  913.     kOTUnknownBusPort            = 0;
  914.     kOTMotherboardBus            = 1;
  915.     kOTNuBus                    = 2;
  916.     kOTPCIBus                    = 3;
  917.     kOTGeoPort                    = 4;
  918.     kOTPCCardBus                = 5;
  919.     kOTFireWireBus                = 6;
  920.     kOTLastBusIndex                = 15;
  921.  
  922.  
  923. TYPE
  924.     OTPortCloseStructPtr = ^OTPortCloseStruct;
  925.     OTPortCloseStruct = RECORD
  926.         fPortRef:                OTPortRef;                                {  The port requested to be closed. }
  927.         fTheProvider:            ProviderRef;                            {  The provider using the port. }
  928.         fDenyReason:            OSStatus;                                {  Set to a negative number to deny the request }
  929.     END;
  930.  
  931. FUNCTION OTCreatePortRef(busType: ByteParameter; devType: UInt16; slot: UInt16; other: UInt16): OTPortRef;
  932. FUNCTION OTGetDeviceTypeFromPortRef(ref: OTPortRef): UInt16;
  933. FUNCTION OTGetBusTypeFromPortRef(ref: OTPortRef): UInt16;
  934. FUNCTION OTGetSlotFromPortRef(ref: OTPortRef; VAR other: UInt16): UInt16;
  935. FUNCTION OTSetDeviceTypeInPortRef(ref: OTPortRef; devType: UInt16): OTPortRef;
  936. FUNCTION OTSetBusTypeInPortRef(ref: OTPortRef; busType: ByteParameter): OTPortRef;
  937. {
  938.      * One OTPortRecord is created for each instance of a port.
  939.      * For Instance 'enet' identifies an ethernet port.
  940.      * A TPortRecord for each ethernet card it finds, with an
  941.      * OTPortRef that will uniquely allow the driver to determine which
  942.      * port it is supposed to open on.
  943. }
  944.  
  945. TYPE
  946.     OTPortRecordPtr = ^OTPortRecord;
  947.     OTPortRecord = RECORD
  948.         fRef:                    OTPortRef;
  949.         fPortFlags:                UInt32;
  950.         fInfoFlags:                UInt32;
  951.         fCapabilities:            UInt32;
  952.         fNumChildPorts:            size_t;
  953.         fChildPorts:            OTPortRefPtr;
  954.         fPortName:                PACKED ARRAY [0..35] OF CHAR;
  955.         fModuleName:            PACKED ARRAY [0..31] OF CHAR;
  956.         fSlotID:                PACKED ARRAY [0..7] OF CHAR;
  957.         fResourceInfo:            PACKED ARRAY [0..31] OF CHAR;
  958.         fReserved:                PACKED ARRAY [0..163] OF CHAR;
  959.     END;
  960.  
  961. {
  962.      * Values for the fInfoFlags field of OTPortRecord
  963.      * kOTPortCanYield and kOTPortCanArbitrate
  964.      * will not be set until the port is used for the first time.
  965. }
  966.  
  967. CONST
  968.     kOTPortIsDLPI                = $00000001;
  969.     kOTPortIsTPI                = $00000002;
  970.     kOTPortCanYield                = $00000004;
  971.     kOTPortCanArbitrate            = $00000008;
  972.     kOTPortIsTransitory            = $00000010;
  973.     kOTPortAutoConnects            = $00000020;
  974.     kOTPortIsSystemRegistered    = $00004000;
  975.     kOTPortIsPrivate            = $00008000;
  976.     kOTPortIsAlias                = $80000000;
  977.  
  978. {
  979.      * Values for the fPortFlags field of TPortRecord
  980.      * If no bits are set, the port is currently inactive.
  981. }
  982.     kOTPortIsActive                = $00000001;
  983.     kOTPortIsDisabled            = $00000002;
  984.     kOTPortIsUnavailable        = $00000004;
  985.     kOTPortIsOffline            = $00000008;
  986.  
  987. {
  988.     -------------------------------------------------------------------------
  989.     TOptionHeader and TOption
  990.     
  991.     This structure describes the contents of a single option in a buffer
  992.     ------------------------------------------------------------------------- 
  993. }
  994.  
  995. TYPE
  996.     TOptionHeaderPtr = ^TOptionHeader;
  997.     TOptionHeader = RECORD
  998.         len:                    UInt32;                                    {  total length of option                 }
  999.                                                                         {  = sizeof(TOptionHeader) + length         }
  1000.                                                                         {      of option value in bytes             }
  1001.         level:                    OTXTILevel;                                {  protocol affected                     }
  1002.         optName:                OTXTIName;                                {  option name                             }
  1003.         status:                    UInt32;                                    {  status value                             }
  1004.     END;
  1005.  
  1006.     TOptionPtr = ^TOption;
  1007.     TOption = RECORD
  1008.         len:                    UInt32;                                    {  total length of option                 }
  1009.                                                                         {  = sizeof(TOption) + length     }
  1010.                                                                         {      of option value in bytes             }
  1011.         level:                    OTXTILevel;                                {  protocol affected                     }
  1012.         optName:                OTXTIName;                                {  option name                             }
  1013.         status:                    UInt32;                                    {  status value                             }
  1014.         value:                    ARRAY [0..0] OF UInt32;                    {  data goes here                         }
  1015.     END;
  1016.  
  1017.  
  1018. CONST
  1019.     kOTOptionHeaderSize            = 16;
  1020.     kOTBooleanOptionDataSize    = 4;
  1021.     kOTBooleanOptionSize        = 20;
  1022.     kOTOneByteOptionSize        = 17;
  1023.     kOTTwoByteOptionSize        = 18;
  1024.     kOTFourByteOptionSize        = 20;
  1025.  
  1026. {
  1027.     -------------------------------------------------------------------------
  1028.     PollRef structure
  1029.     
  1030.     This is used with the OTStreamPoll function
  1031.     ------------------------------------------------------------------------- 
  1032. }
  1033.  
  1034. TYPE
  1035.     PollRefPtr = ^PollRef;
  1036.     PollRef = RECORD
  1037.         filler:                    LONGINT;
  1038.         events:                    INTEGER;
  1039.         revents:                INTEGER;
  1040.         ref:                    StreamRef;
  1041.     END;
  1042.  
  1043. {
  1044.     -------------------------------------------------------------------------
  1045.     OTClientList structure
  1046.     
  1047.     This is used with the OTYieldPortRequest function.
  1048.     ------------------------------------------------------------------------- 
  1049. }
  1050.     OTClientListPtr = ^OTClientList;
  1051.     OTClientList = RECORD
  1052.         fNumClients:            size_t;
  1053.         fBuffer:                PACKED ARRAY [0..3] OF UInt8;
  1054.     END;
  1055.  
  1056. {
  1057.     -------------------------------------------------------------------------
  1058.     OTData
  1059.     
  1060.     This is a structure that may be used in a TNetbuf or netbuf to send
  1061.     non-contiguous data.  Set the 'len' field of the netbuf to the
  1062.     constant kNetbufDataIsOTData to signal that the 'buf' field of the
  1063.     netbuf actually points to one of these structures instead of a
  1064.     memory buffer.
  1065.     ------------------------------------------------------------------------- 
  1066. }
  1067.     OTDataPtr = ^OTData;
  1068.     OTData = RECORD
  1069.         fNext:                    Ptr;
  1070.         fData:                    Ptr;
  1071.         fLen:                    size_t;
  1072.     END;
  1073.  
  1074.  
  1075. CONST
  1076.     kNetbufDataIsOTData            = $FFFFFFFE;
  1077.  
  1078. {
  1079.     -------------------------------------------------------------------------
  1080.     OTBuffer
  1081.  
  1082.     This is the structure that is used for no-copy receives.
  1083.     When you are done with it, you must call the OTReleaseBuffer function.
  1084.     For best performance, you need to call OTReleaseBuffer quickly.  Only
  1085.     data netbufs may use this - no netbufs for addresses or options, or the like.
  1086.     ------------------------------------------------------------------------- 
  1087. }
  1088.  
  1089. TYPE
  1090.     OTBufferPtr = ^OTBuffer;
  1091.     OTBuffer = RECORD
  1092.         fLink:                    Ptr;                                    {  b_next & b_prev }
  1093.         fLink2:                    Ptr;
  1094.         fNext:                    OTBufferPtr;                            {  b_cont }
  1095.         fData:                    Ptr;                                    {  b_rptr }
  1096.         fLen:                    size_t;                                    {  b_wptr }
  1097.         fSave:                    Ptr;                                    {  b_datap }
  1098.         fBand:                    SInt8;                                    {  b_band }
  1099.         fType:                    SInt8;                                    {  b_pad1 }
  1100.         fPad1:                    SInt8;
  1101.         fFlags:                    SInt8;                                    {  b_flag }
  1102.     END;
  1103.  
  1104. {
  1105.     -------------------------------------------------------------------------
  1106.     OTBufferInfo
  1107.     
  1108.     This structure is used with OTReadBuffer to keep track of where you
  1109.     are in the buffer, since the OTBuffer is "read-only".
  1110.     ------------------------------------------------------------------------- 
  1111. }
  1112.     OTBufferInfoPtr = ^OTBufferInfo;
  1113.     OTBufferInfo = RECORD
  1114.         fBuffer:                OTBufferPtr;
  1115.         fOffset:                size_t;
  1116.         fPad:                    SInt8;
  1117.         fFiller:                SInt8;
  1118.     END;
  1119.  
  1120.  
  1121. CONST
  1122.     kOTNetbufDataIsOTBufferStar    = $FFFFFFFD;
  1123.  
  1124. {
  1125.     -------------------------------------------------------------------------
  1126.     TNetbuf
  1127.     
  1128.     This structure is the basic structure used to pass data back and forth
  1129.     between the Open Transport protocols and their clients
  1130.     ------------------------------------------------------------------------- 
  1131. }
  1132.  
  1133. TYPE
  1134.     TNetbufPtr = ^TNetbuf;
  1135.     TNetbuf = RECORD
  1136.         maxlen:                    size_t;
  1137.         len:                    size_t;
  1138.         buf:                    Ptr;
  1139.     END;
  1140.  
  1141. {
  1142.     -------------------------------------------------------------------------
  1143.     TBind
  1144.     
  1145.     Structure passed to GetProtAddress, ResolveAddress and Bind
  1146.     ------------------------------------------------------------------------- 
  1147. }
  1148.     TBindPtr = ^TBind;
  1149.     TBind = RECORD
  1150.         addr:                    TNetbuf;
  1151.         qlen:                    OTQLen;
  1152.     END;
  1153.  
  1154. {
  1155.     -------------------------------------------------------------------------
  1156.     TDiscon
  1157.     
  1158.     Structure passed to RcvDisconnect to find out additional information
  1159.     about the disconnect
  1160.     ------------------------------------------------------------------------- 
  1161. }
  1162.     TDisconPtr = ^TDiscon;
  1163.     TDiscon = RECORD
  1164.         udata:                    TNetbuf;
  1165.         reason:                    OTReason;
  1166.         sequence:                OTSequence;
  1167.     END;
  1168.  
  1169. {
  1170.     -------------------------------------------------------------------------
  1171.     TCall
  1172.     
  1173.     Structure passed to Connect, RcvConnect, Listen, Accept, and
  1174.     SndDisconnect to describe the connection.
  1175.     ------------------------------------------------------------------------- 
  1176. }
  1177.     TCallPtr = ^TCall;
  1178.     TCall = RECORD
  1179.         addr:                    TNetbuf;
  1180.         opt:                    TNetbuf;
  1181.         udata:                    TNetbuf;
  1182.         sequence:                OTSequence;
  1183.     END;
  1184.  
  1185. {
  1186.     -------------------------------------------------------------------------
  1187.     TUnitData
  1188.     
  1189.     Structure passed to SndUData and RcvUData to describe the datagram
  1190.     ------------------------------------------------------------------------- 
  1191. }
  1192.     TUnitDataPtr = ^TUnitData;
  1193.     TUnitData = RECORD
  1194.         addr:                    TNetbuf;
  1195.         opt:                    TNetbuf;
  1196.         udata:                    TNetbuf;
  1197.     END;
  1198.  
  1199. {
  1200.     -------------------------------------------------------------------------
  1201.     TUDErr
  1202.     
  1203.     Structure passed to RcvUDErr to find out about a datagram error
  1204.     ------------------------------------------------------------------------- 
  1205. }
  1206.     TUDErrPtr = ^TUDErr;
  1207.     TUDErr = RECORD
  1208.         addr:                    TNetbuf;
  1209.         opt:                    TNetbuf;
  1210.         error:                    SInt32;
  1211.     END;
  1212.  
  1213. {
  1214.     -------------------------------------------------------------------------
  1215.     TOptMgmt
  1216.     
  1217.     Structure passed to the OptionManagement call to read or set protocol
  1218.     options.
  1219.     ------------------------------------------------------------------------- 
  1220. }
  1221.     TOptMgmtPtr = ^TOptMgmt;
  1222.     TOptMgmt = RECORD
  1223.         opt:                    TNetbuf;
  1224.         flags:                    OTFlags;
  1225.     END;
  1226.  
  1227. {
  1228.     -------------------------------------------------------------------------
  1229.     TRequest
  1230.     
  1231.     Structure passed to SndRequest and RcvRequest that contains the information
  1232.     about the request
  1233.     ------------------------------------------------------------------------- 
  1234. }
  1235.     TRequestPtr = ^TRequest;
  1236.     TRequest = RECORD
  1237.         data:                    TNetbuf;
  1238.         opt:                    TNetbuf;
  1239.         sequence:                OTSequence;
  1240.     END;
  1241.  
  1242. {
  1243.     -------------------------------------------------------------------------
  1244.     TReply
  1245.     
  1246.     Structure passed to SndReply to send a reply to an incoming request
  1247.     ------------------------------------------------------------------------- 
  1248. }
  1249.     TReplyPtr = ^TReply;
  1250.     TReply = RECORD
  1251.         data:                    TNetbuf;
  1252.         opt:                    TNetbuf;
  1253.         sequence:                OTSequence;
  1254.     END;
  1255.  
  1256. {
  1257.     -------------------------------------------------------------------------
  1258.     TUnitRequest
  1259.     
  1260.     Structure passed to SndURequest and RcvURequest that contains the information
  1261.     about the request
  1262.     ------------------------------------------------------------------------- 
  1263. }
  1264.     TUnitRequestPtr = ^TUnitRequest;
  1265.     TUnitRequest = RECORD
  1266.         addr:                    TNetbuf;
  1267.         opt:                    TNetbuf;
  1268.         udata:                    TNetbuf;
  1269.         sequence:                OTSequence;
  1270.     END;
  1271.  
  1272. {
  1273.     -------------------------------------------------------------------------
  1274.     TUnitReply
  1275.     
  1276.     Structure passed to SndUReply to send a reply to an incoming request
  1277.     ------------------------------------------------------------------------- 
  1278. }
  1279.     TUnitReplyPtr = ^TUnitReply;
  1280.     TUnitReply = RECORD
  1281.         opt:                    TNetbuf;
  1282.         udata:                    TNetbuf;
  1283.         sequence:                OTSequence;
  1284.     END;
  1285.  
  1286. {
  1287.     -------------------------------------------------------------------------
  1288.     TRegisterRequest
  1289.     ------------------------------------------------------------------------- 
  1290. }
  1291.     TRegisterRequestPtr = ^TRegisterRequest;
  1292.     TRegisterRequest = RECORD
  1293.         name:                    TNetbuf;
  1294.         addr:                    TNetbuf;
  1295.         flags:                    OTFlags;
  1296.     END;
  1297.  
  1298. {
  1299.     -------------------------------------------------------------------------
  1300.     TRegisterReply
  1301.     ------------------------------------------------------------------------- 
  1302. }
  1303.     TRegisterReplyPtr = ^TRegisterReply;
  1304.     TRegisterReply = RECORD
  1305.         addr:                    TNetbuf;
  1306.         nameid:                    OTNameID;
  1307.     END;
  1308.  
  1309. {
  1310.     -------------------------------------------------------------------------
  1311.     TLookupRequest
  1312.     ------------------------------------------------------------------------- 
  1313. }
  1314.     TLookupRequestPtr = ^TLookupRequest;
  1315.     TLookupRequest = RECORD
  1316.         name:                    TNetbuf;
  1317.         addr:                    TNetbuf;
  1318.         maxcnt:                    UInt32;
  1319.         timeout:                OTTimeout;
  1320.         flags:                    OTFlags;
  1321.     END;
  1322.  
  1323. {
  1324.     -------------------------------------------------------------------------
  1325.     TLookupReply 
  1326.     
  1327.     Structure used by Mapper protocols to return the results of name Lookups
  1328.     ------------------------------------------------------------------------- 
  1329. }
  1330. {
  1331.      * This is the structure returned by the mapper for names that are
  1332.      * looked up.  
  1333. }
  1334.     TLookupBufferPtr = ^TLookupBuffer;
  1335.     TLookupBuffer = RECORD
  1336.         fAddressLength:            UInt16;
  1337.         fNameLength:            UInt16;
  1338.         fAddressBuffer:            SInt8;
  1339.     END;
  1340.  
  1341.     TLookupReplyPtr = ^TLookupReply;
  1342.     TLookupReply = RECORD
  1343.         names:                    TNetbuf;
  1344.         rspcount:                UInt32;
  1345.     END;
  1346.  
  1347. {
  1348. ******************************************************************************
  1349. ** C Interfaces to Open Transport
  1350. *******************************************************************************
  1351. }
  1352. {
  1353.     -------------------------------------------------------------------------
  1354.     Initializing and shutting down Open Transport
  1355.     ------------------------------------------------------------------------- 
  1356. }
  1357. {$IFC NOT OTKERNEL }
  1358. FUNCTION InitOpenTransport: OSStatus;
  1359. FUNCTION InitOpenTransportUtilities: OSStatus;
  1360. PROCEDURE CloseOpenTransport;
  1361. {
  1362.  This registers yourself as a client for any miscellaneous Open Transport
  1363.  notifications that come along. CloseOpenTransport will automatically do
  1364.  an OTUnregisterAsClient, if you have not already done so.
  1365. }
  1366. FUNCTION OTRegisterAsClient(name: OTClientName; proc: OTNotifyProcPtr): OSStatus;
  1367. FUNCTION OTUnregisterAsClient: OSStatus;
  1368. {$ENDC}
  1369. {
  1370.     -------------------------------------------------------------------------
  1371.     Interrupt processing
  1372.     
  1373.     These routine must be used by interrupt, deferred task, vbl, and time
  1374.     manager routines to bracket any calls to OpenTransport.
  1375.     ------------------------------------------------------------------------- 
  1376. }
  1377. PROCEDURE OTEnterInterrupt;
  1378. PROCEDURE OTLeaveInterrupt;
  1379.  
  1380. TYPE
  1381.     OTProcessProcPtr = ProcPtr;  { PROCEDURE OTProcess(arg: UNIV Ptr); }
  1382.  
  1383. FUNCTION OTCreateDeferredTask(proc: OTProcessProcPtr; arg: UNIV Ptr): LONGINT;
  1384. FUNCTION OTScheduleDeferredTask(dtCookie: LONGINT): BOOLEAN;
  1385. FUNCTION OTScheduleInterruptTask(dtCookie: LONGINT): BOOLEAN;
  1386. FUNCTION OTDestroyDeferredTask(dtCookie: LONGINT): OSStatus;
  1387. {$IFC NOT OTKERNEL }
  1388. FUNCTION OTCreateSystemTask(proc: OTProcessProcPtr; arg: UNIV Ptr): LONGINT;
  1389. FUNCTION OTDestroySystemTask(stCookie: LONGINT): OSStatus;
  1390. FUNCTION OTScheduleSystemTask(stCookie: LONGINT): BOOLEAN;
  1391. FUNCTION OTCancelSystemTask(stCookie: LONGINT): BOOLEAN;
  1392. FUNCTION OTCanMakeSyncCall: BOOLEAN;
  1393. {$ENDC}
  1394. FUNCTION OTIsAtInterruptLevel: BOOLEAN; C;
  1395. FUNCTION OTCanLoadLibraries: BOOLEAN; C;
  1396. {
  1397.     -------------------------------------------------------------------------
  1398.     Functions for dealing with port
  1399.     ------------------------------------------------------------------------- 
  1400. }
  1401. {$IFC NOT OTKERNEL }
  1402. FUNCTION OTGetIndexedPort(VAR record1: OTPortRecord; index: size_t): BOOLEAN;
  1403. FUNCTION OTFindPort(VAR record1: OTPortRecord; portName: ConstCStringPtr): BOOLEAN;
  1404. FUNCTION OTFindPortByRef(VAR record1: OTPortRecord; ref: OTPortRef): BOOLEAN;
  1405. FUNCTION OTRegisterPort(VAR portInfo: OTPortRecord; ref: UNIV Ptr): OSStatus; C;
  1406. FUNCTION OTUnregisterPort(portName: ConstCStringPtr; VAR cookiePtrPTr: UNIV Ptr): OSStatus; C;
  1407. FUNCTION OTChangePortState(ref: OTPortRef; theChange: OTEventCode; why: OTResult): OSStatus; C;
  1408. {$ENDC}
  1409. {
  1410.     -------------------------------------------------------------------------
  1411.     Interface to providers
  1412.     ------------------------------------------------------------------------- 
  1413. }
  1414.  
  1415. TYPE
  1416.     strbufPtr = ^strbuf;
  1417.     strbuf = RECORD
  1418.         maxlen:                    LONGINT;                                {  max buffer length  }
  1419.         len:                    LONGINT;                                {  length of data  }
  1420.         buf:                    CStringPtr;                                {  pointer to buffer  }
  1421.     END;
  1422.  
  1423. {$IFC NOT OTKERNEL }
  1424. FUNCTION OTAsyncOpenProvider(config: OTConfigurationPtr; flags: OTOpenFlags; proc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  1425. FUNCTION OTOpenProvider(config: OTConfigurationPtr; flags: OTOpenFlags; VAR errPtr: OSStatus): ProviderRef;
  1426. FUNCTION OTCloseProvider(ref: ProviderRef): OSStatus;
  1427. FUNCTION OTTransferProviderOwnership(ref: ProviderRef; prevOwner: OTClient; VAR errPtr: OSStatus): ProviderRef;
  1428. FUNCTION OTWhoAmI: OTClient;
  1429. FUNCTION OTGetProviderPortRef(ref: ProviderRef): OTPortRef;
  1430. FUNCTION OTIoctl(ref: ProviderRef; cmd: UInt32; data: UNIV Ptr): SInt32;
  1431. FUNCTION OTGetMessage(ref: ProviderRef; VAR ctlbuf: strbuf; VAR databuf: strbuf; VAR flagPtr: OTFlags): OTResult;
  1432. FUNCTION OTGetPriorityMessage(ref: ProviderRef; VAR ctlbuf: strbuf; VAR databuf: strbuf; VAR bandPtr: OTBand; VAR flagPtr: OTFlags): OTResult;
  1433. FUNCTION OTPutMessage(ref: ProviderRef; {CONST}VAR ctlbuf: strbuf; {CONST}VAR databuf: strbuf; flags: OTFlags): OSStatus;
  1434. FUNCTION OTPutPriorityMessage(ref: ProviderRef; {CONST}VAR ctlbuf: strbuf; {CONST}VAR databuf: strbuf; band: OTBand; flags: OTFlags): OSStatus;
  1435. FUNCTION OTSetAsynchronous(ref: ProviderRef): OSStatus;
  1436. FUNCTION OTSetSynchronous(ref: ProviderRef): OSStatus;
  1437. FUNCTION OTIsSynchronous(ref: ProviderRef): BOOLEAN;
  1438. FUNCTION OTSetBlocking(ref: ProviderRef): OSStatus;
  1439. FUNCTION OTSetNonBlocking(ref: ProviderRef): OSStatus;
  1440. FUNCTION OTIsBlocking(ref: ProviderRef): BOOLEAN;
  1441. FUNCTION OTInstallNotifier(ref: ProviderRef; proc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  1442. FUNCTION OTUseSyncIdleEvents(ref: ProviderRef; useEvents: BOOLEAN): OSStatus;
  1443. PROCEDURE OTRemoveNotifier(ref: ProviderRef);
  1444. PROCEDURE OTLeaveNotifier(ref: ProviderRef);
  1445. FUNCTION OTEnterNotifier(ref: ProviderRef): BOOLEAN;
  1446. FUNCTION OTAckSends(ref: ProviderRef): OSStatus;
  1447. FUNCTION OTDontAckSends(ref: ProviderRef): OSStatus;
  1448. FUNCTION OTIsAckingSends(ref: ProviderRef): BOOLEAN;
  1449. FUNCTION OTCancelSynchronousCalls(ref: ProviderRef; err: OSStatus): OSStatus;
  1450. {$ENDC}
  1451. {
  1452.     -------------------------------------------------------------------------
  1453.     Interface to endpoints
  1454.     ------------------------------------------------------------------------- 
  1455. }
  1456. {$IFC NOT OTKERNEL }
  1457. {  Open/Close }
  1458. FUNCTION OTOpenEndpoint(config: OTConfigurationPtr; oflag: OTOpenFlags; info: TEndpointInfoPtr; VAR err: OSStatus): EndpointRef;
  1459. FUNCTION OTAsyncOpenEndpoint(config: OTConfigurationPtr; oflag: OTOpenFlags; info: TEndpointInfoPtr; proc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  1460. {  Misc Information }
  1461. FUNCTION OTGetEndpointInfo(ref: EndpointRef; info: TEndpointInfoPtr): OSStatus;
  1462. FUNCTION OTGetEndpointState(ref: EndpointRef): OTResult;
  1463. FUNCTION OTLook(ref: EndpointRef): OTResult;
  1464. FUNCTION OTSync(ref: EndpointRef): OTResult;
  1465. FUNCTION OTCountDataBytes(ref: EndpointRef; VAR countPtr: size_t): OTResult;
  1466. FUNCTION OTGetProtAddress(ref: EndpointRef; boundAddr: TBindPtr; peerAddr: TBindPtr): OSStatus;
  1467. FUNCTION OTResolveAddress(ref: EndpointRef; reqAddr: TBindPtr; retAddr: TBindPtr; timeOut: OTTimeout): OSStatus;
  1468. {  Allocating structures }
  1469. FUNCTION OTAlloc(ref: EndpointRef; structType: OTStructType; fields: UInt32; VAR err: OSStatus): Ptr;
  1470. FUNCTION OTFree(ptr: UNIV Ptr; structType: OTStructType): OTResult;
  1471. {  Option management }
  1472. FUNCTION OTOptionManagement(ref: EndpointRef; req: TOptMgmtPtr; ret: TOptMgmtPtr): OSStatus;
  1473. {  Bind/Unbind }
  1474. FUNCTION OTBind(ref: EndpointRef; reqAddr: TBindPtr; retAddr: TBindPtr): OSStatus;
  1475. FUNCTION OTUnbind(ref: EndpointRef): OSStatus;
  1476. {  Connection creation/tear-down }
  1477. FUNCTION OTConnect(ref: EndpointRef; sndCall: TCallPtr; rcvCall: TCallPtr): OSStatus;
  1478. FUNCTION OTRcvConnect(ref: EndpointRef; call: TCallPtr): OSStatus;
  1479. FUNCTION OTListen(ref: EndpointRef; call: TCallPtr): OSStatus;
  1480. FUNCTION OTAccept(ref: EndpointRef; resRef: EndpointRef; call: TCallPtr): OSStatus;
  1481. FUNCTION OTSndDisconnect(ref: EndpointRef; call: TCallPtr): OSStatus;
  1482. FUNCTION OTSndOrderlyDisconnect(ref: EndpointRef): OSStatus;
  1483. FUNCTION OTRcvDisconnect(ref: EndpointRef; discon: TDisconPtr): OSStatus;
  1484. FUNCTION OTRcvOrderlyDisconnect(ref: EndpointRef): OSStatus;
  1485. {  Connection-oriented send/receive }
  1486. FUNCTION OTRcv(ref: EndpointRef; buf: UNIV Ptr; nbytes: size_t; VAR flags: OTFlags): OTResult;
  1487. FUNCTION OTSnd(ref: EndpointRef; buf: UNIV Ptr; nbytes: size_t; flags: OTFlags): OTResult;
  1488. {  non-connection oriented send/receive }
  1489. FUNCTION OTSndUData(ref: EndpointRef; udata: TUnitDataPtr): OSStatus;
  1490. FUNCTION OTRcvUData(ref: EndpointRef; udata: TUnitDataPtr; VAR flags: OTFlags): OSStatus;
  1491. FUNCTION OTRcvUDErr(ref: EndpointRef; uderr: TUDErrPtr): OSStatus;
  1492. {  Connection-oriented transactions }
  1493. FUNCTION OTSndRequest(ref: EndpointRef; req: TRequestPtr; reqFlags: OTFlags): OSStatus;
  1494. FUNCTION OTRcvReply(ref: EndpointRef; reply: TReplyPtr; VAR replyFlags: OTFlags): OSStatus;
  1495. FUNCTION OTSndReply(ref: EndpointRef; reply: TReplyPtr; replyFlags: OTFlags): OSStatus;
  1496. FUNCTION OTRcvRequest(ref: EndpointRef; req: TRequestPtr; VAR reqFlags: OTFlags): OSStatus;
  1497. FUNCTION OTCancelRequest(ref: EndpointRef; sequence: OTSequence): OSStatus;
  1498. FUNCTION OTCancelReply(ref: EndpointRef; sequence: OTSequence): OSStatus;
  1499. {  Connectionless transactions }
  1500. FUNCTION OTSndURequest(ref: EndpointRef; req: TUnitRequestPtr; reqFlags: OTFlags): OSStatus;
  1501. FUNCTION OTRcvUReply(ref: EndpointRef; reply: TUnitReplyPtr; VAR replyFlags: OTFlags): OSStatus;
  1502. FUNCTION OTSndUReply(ref: EndpointRef; reply: TUnitReplyPtr; replyFlags: OTFlags): OSStatus;
  1503. FUNCTION OTRcvURequest(ref: EndpointRef; req: TUnitRequestPtr; VAR reqFlags: OTFlags): OSStatus;
  1504. FUNCTION OTCancelURequest(ref: EndpointRef; seq: OTSequence): OSStatus;
  1505. FUNCTION OTCancelUReply(ref: EndpointRef; seq: OTSequence): OSStatus;
  1506. {
  1507.     -------------------------------------------------------------------------
  1508.     Interface to mappers
  1509.     ------------------------------------------------------------------------- 
  1510. }
  1511. FUNCTION OTAsyncOpenMapper(config: OTConfigurationPtr; oflag: OTOpenFlags; proc: OTNotifyProcPtr; contextPtr: UNIV Ptr): OSStatus;
  1512. FUNCTION OTOpenMapper(config: OTConfigurationPtr; oflag: OTOpenFlags; VAR err: OSStatus): MapperRef;
  1513. FUNCTION OTRegisterName(ref: MapperRef; req: TRegisterRequestPtr; VAR reply: TRegisterReply): OSStatus;
  1514. FUNCTION OTDeleteName(ref: MapperRef; name: TNetbufPtr): OSStatus;
  1515. FUNCTION OTDeleteNameByID(ref: MapperRef; nameID: OTNameID): OSStatus;
  1516. FUNCTION OTLookupName(ref: MapperRef; req: TLookupRequestPtr; reply: TLookupReplyPtr): OSStatus;
  1517. {
  1518.     -------------------------------------------------------------------------
  1519.     Miscellaneous and generic functions
  1520.     ------------------------------------------------------------------------- 
  1521. }
  1522. FUNCTION OTAllocMem(size: size_t): Ptr; C;
  1523. PROCEDURE OTFreeMem(memptr: UNIV Ptr); C;
  1524. PROCEDURE OTDelay(seconds: UInt32);
  1525. PROCEDURE OTIdle;
  1526. FUNCTION OTCreateConfiguration(path: ConstCStringPtr): OTConfigurationPtr;
  1527. FUNCTION OTCloneConfiguration(cfig: OTConfigurationPtr): OTConfigurationPtr;
  1528. PROCEDURE OTDestroyConfiguration(cfig: OTConfigurationPtr);
  1529. FUNCTION OTCreateOptions(endPtName: ConstCStringPtr; strPtr: CStringPtrPtr; VAR buf: TNetbuf): OSStatus;
  1530. FUNCTION OTCreateOptionString(endPtName: ConstCStringPtr; VAR opt: TOptionPtr; bufEnd: UNIV Ptr; strPTr: CStringPtr; stringSize: size_t): OSStatus;
  1531. FUNCTION OTNextOption(VAR buffer: UInt8; buflen: UInt32; VAR prevOptPtr: TOptionPtr): OSStatus;
  1532. FUNCTION OTFindOption(VAR buffer: UInt8; buflen: UInt32; level: OTXTILevel; name: OTXTIName): TOptionPtr;
  1533. {$ENDC}
  1534. {
  1535. ******************************************************************************
  1536. ** Open Transport Utility routines
  1537. **
  1538. ** These routines are available to both client and kernel
  1539. *******************************************************************************
  1540. }
  1541. {
  1542.     -------------------------------------------------------------------------
  1543.     ** Memory functions
  1544.     ------------------------------------------------------------------------- 
  1545. }
  1546. PROCEDURE OTMemcpy(dest: UNIV Ptr; src: UNIV Ptr; nBytes: size_t); C;
  1547. FUNCTION OTMemcmp(mem1: UNIV Ptr; mem2: UNIV Ptr; nBytes: size_t): BOOLEAN; C;
  1548. PROCEDURE OTMemmove(dest: UNIV Ptr; src: UNIV Ptr; nBytes: size_t); C;
  1549. PROCEDURE OTMemzero(dest: UNIV Ptr; nBytes: size_t); C;
  1550. PROCEDURE OTMemset(dest: UNIV Ptr; toSet: uchar_p; nBytes: size_t); C;
  1551. FUNCTION OTStrLength(strPtr: ConstCStringPtr): size_t; C;
  1552. PROCEDURE OTStrCopy(strTo: CStringPtr; strFrom: ConstCStringPtr); C;
  1553. PROCEDURE OTStrCat(strTo: CStringPtr; strFrom: ConstCStringPtr); C;
  1554. FUNCTION OTStrEqual(strPtr1: ConstCStringPtr; strPtr2: ConstCStringPtr): BOOLEAN; C;
  1555. {
  1556.     -------------------------------------------------------------------------
  1557.     ** Time functions
  1558.     **    
  1559.     **    OTGetTimeStamp returns time in "tick" numbers, stored in 64 bits.
  1560.     **    This timestamp can be used as a base number for calculating elapsed 
  1561.     **    time.
  1562.     **    OTSubtractTimeStamps returns a pointer to the "result" parameter.
  1563.     **        
  1564.     **    OTGetClockTimeInSecs returns time since Open Transport was initialized
  1565.     **        in seconds.
  1566.     ------------------------------------------------------------------------- 
  1567. }
  1568.  
  1569. TYPE
  1570.     OTTimeStamp                            = UnsignedWide;
  1571.     OTTimeStampPtr                         = ^OTTimeStamp;
  1572. PROCEDURE OTGetTimeStamp(VAR stamp: OTTimeStamp); C;
  1573. FUNCTION OTSubtractTimeStamps(VAR result: OTTimeStamp; VAR startTime: OTTimeStamp; VAR endTime: OTTimeStamp): OTTimeStampPtr; C;
  1574. FUNCTION OTTimeStampInMilliseconds(VAR delta: OTTimeStamp): UInt32; C;
  1575. FUNCTION OTTimeStampInMicroseconds(VAR delta: OTTimeStamp): UInt32; C;
  1576. FUNCTION OTElapsedMilliseconds(VAR startTime: OTTimeStamp): UInt32; C;
  1577. FUNCTION OTElapsedMicroseconds(VAR startTime: OTTimeStamp): UInt32; C;
  1578. FUNCTION OTGetClockTimeInSecs: UInt32; C;
  1579. {
  1580.     -------------------------------------------------------------------------
  1581.     ** OTLIFO
  1582.     **
  1583.     ** These are functions to implement a LIFO list that is interrupt-safe.
  1584.     ** The only function which is not is OTReverseList.  Normally, you create
  1585.     ** a LIFO list, populate it at interrupt time, and then use OTLIFOStealList
  1586.     ** to atomically remove the list, and OTReverseList to flip the list so that
  1587.     ** it is a FIFO list, which tends to be more useful.
  1588.     ------------------------------------------------------------------------- 
  1589. }
  1590.  
  1591. TYPE
  1592.     OTLinkPtr = ^OTLink;
  1593.     OTLIFOPtr = ^OTLIFO;
  1594.     OTLIFO = RECORD
  1595.         fHead:                    OTLinkPtr;
  1596.     END;
  1597.  
  1598.     OTLink = RECORD
  1599.         fNext:                    OTLinkPtr;
  1600.     END;
  1601.  
  1602. {
  1603.  This function puts "object" on the listHead, and places the
  1604.  previous value at listHead into the pointer at "object" plus
  1605.  linkOffset.
  1606. }
  1607. PROCEDURE OTEnqueue(VAR listHead: UNIV Ptr; object: UNIV Ptr; linkOffset: size_t); C;
  1608. {
  1609.  This function returns the head object of the list, and places
  1610.  the pointer at "object" + linkOffset into the listHead
  1611. }
  1612. FUNCTION OTDequeue(VAR listHead: UNIV Ptr; linkOffset: size_t): Ptr; C;
  1613. {  This function atomically enqueues the link onto the list }
  1614. PROCEDURE OTLIFOEnqueue(VAR list: OTLIFO; VAR link: OTLink); C;
  1615. {
  1616.  This function atomically dequeues the first element
  1617.  on the list
  1618. }
  1619. FUNCTION OTLIFODequeue(VAR list: OTLIFO): OTLinkPtr; C;
  1620. {
  1621.  This function atomically empties the list and returns a
  1622.  pointer to the first element on the list
  1623. }
  1624. FUNCTION OTLIFOStealList(VAR list: OTLIFO): OTLinkPtr; C;
  1625. {
  1626.  This function reverses a list that was stolen by
  1627.  OTLIFOStealList.  It is NOT atomic.  It returns the
  1628.  new starting list.
  1629. }
  1630. FUNCTION OTReverseList(VAR list: OTLink): OTLinkPtr; C;
  1631. {
  1632.     -------------------------------------------------------------------------
  1633.     ** OTList
  1634.     **
  1635.     ** An OTList is a non-interrupt-safe list, but has more features than the
  1636.     ** OTLIFO list. It is a standard singly-linked list.
  1637.     ------------------------------------------------------------------------- 
  1638. }
  1639.  
  1640. TYPE
  1641.     OTListPtr = ^OTList;
  1642.     OTList = RECORD
  1643.         fHead:                    OTLinkPtr;
  1644.     END;
  1645.  
  1646.     OTListSearchProcPtr = ProcPtr;  { FUNCTION OTListSearch(ref: UNIV Ptr; VAR linkToCheck: OTLink): BOOLEAN; C; }
  1647.  
  1648. {  Add the link to the list at the front }
  1649. PROCEDURE OTAddFirst(VAR list: OTList; VAR link: OTLink); C;
  1650. {  Add the link to the list at the end }
  1651. PROCEDURE OTAddLast(VAR list: OTList; VAR link: OTLink); C;
  1652. {  Remove the first link from the list }
  1653. FUNCTION OTRemoveFirst(VAR list: OTList): OTLinkPtr; C;
  1654. {  Remove the last link from the list }
  1655. FUNCTION OTRemoveLast(VAR list: OTList): OTLinkPtr; C;
  1656. {  Return the first link from the list }
  1657. FUNCTION OTGetFirst(VAR list: OTList): OTLinkPtr; C;
  1658. {  Return the last link from the list }
  1659. FUNCTION OTGetLast(VAR list: OTList): OTLinkPtr; C;
  1660. {  Return true if the link is present in the list }
  1661. FUNCTION OTIsInList(VAR list: OTList; VAR link: OTLink): BOOLEAN; C;
  1662. {
  1663.  Find a link in the list which matches the search criteria
  1664.  established by the search proc and the refPtr.  This is done
  1665.  by calling the search proc, passing it the refPtr and each
  1666.  link in the list, until the search proc returns true.
  1667.  NULL is returned if the search proc never returned true.
  1668. }
  1669. FUNCTION OTFindLink(VAR listPtr: OTList; procPtr: OTListSearchProcPtr; refPtr: UNIV Ptr): OTLinkPtr; C;
  1670. {  Remove the specified link from the list, returning true if it was found }
  1671. FUNCTION OTRemoveLink(VAR listPtr: OTList; VAR linkPtr: OTLink): BOOLEAN; C;
  1672. {  Similar to OTFindLink, but it also removes it from the list. }
  1673. FUNCTION OTFindAndRemoveLink(VAR list: OTList; proc: OTListSearchProcPtr; refPtr: UNIV Ptr): OTLinkPtr; C;
  1674. {  Return the "index"th link in the list }
  1675. FUNCTION OTGetIndexedLink(VAR list: OTList; index: size_t): OTLinkPtr; C;
  1676. {
  1677.     -------------------------------------------------------------------------
  1678.     ** Atomic Operations
  1679.     **
  1680.     ** The Bit operations return the previous value of the bit (0 or non-zero).
  1681.     ** The memory pointed to must be a single byte and only bits 0 through 7 are
  1682.     ** valid.  Bit 0 corresponds to a mask of 0x01, and Bit 7 to a mask of 0x80.
  1683.     ------------------------------------------------------------------------- 
  1684. }
  1685.  
  1686. TYPE
  1687.     OTLock                                = UInt8;
  1688. FUNCTION OTAtomicSetBit(VAR ptr: UInt8; len: size_t): BOOLEAN; C;
  1689. FUNCTION OTAtomicClearBit(VAR ptr: UInt8; len: size_t): BOOLEAN; C;
  1690. FUNCTION OTAtomicTestBit(VAR ptr: UInt8; len: size_t): BOOLEAN; C;
  1691. {
  1692.  WARNING! void* and UInt32 locations MUST be on 4-byte boundaries.
  1693.             UInt16 locations must not cross a 4-byte boundary.
  1694. }
  1695. FUNCTION OTCompareAndSwapPtr(oldValue: UNIV Ptr; newValue: UNIV Ptr; VAR location: UNIV Ptr): BOOLEAN; C;
  1696. FUNCTION OTCompareAndSwap32(oldValue: UInt32; newValue: UInt32; VAR location: UInt32): BOOLEAN; C;
  1697. FUNCTION OTCompareAndSwap16(oldValue: UInt32; newValue: UInt32; VAR location: UInt16): BOOLEAN; C;
  1698. FUNCTION OTCompareAndSwap8(oldValue: UInt32; newValue: UInt32; VAR location: UInt8): BOOLEAN; C;
  1699. {
  1700.  WARNING! UInt32 locations MUST be on 4-byte boundaries.
  1701.             UInt16 locations must not cross a 4-byte boundary.
  1702. }
  1703. FUNCTION OTAtomicAdd32(val: SInt32; VAR ptr: SInt32): SInt32; C;
  1704. FUNCTION OTAtomicAdd16(val: SInt16; VAR ptr: SInt16): SInt16; C;
  1705. FUNCTION OTAtomicAdd8(val: SInt8; VAR ptr: SInt8): SInt8; C;
  1706. {$ALIGN RESET}
  1707. {$POP}
  1708.  
  1709. {$SETC UsingIncludes := OpenTransportIncludes}
  1710.  
  1711. {$ENDC} {__OPENTRANSPORT__}
  1712.  
  1713. {$IFC NOT UsingIncludes}
  1714.  END.
  1715. {$ENDC}
  1716.